<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});



/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

// 分类列表
Route::get('/types', "Home\PostController@types");

// 文章列表api接口程序
Route::post('/post/list', "Home\PostController@list");

// 分类文章api接口
Route::get('/post/type/{id}', "Home\PostController@type");

// 用户注册
Route::post('/user/register', "Home\UserController@register");

// 用户登录
Route::post('/user/login', "Home\UserController@login");


// 收藏，取消收藏 api接口
Route::get('/post/favorite/{id}', "Home\PostController@favorite");
Route::get('/post/unfavorite/{id}', "Home\PostController@unfavorite");

// 发布文章
Route::get('/post/write', "Home\PostController@write")->name("write");
Route::post('/post/save', "Home\PostController@save")->name("save");

// 管理文章
Route::get('/post/mypost', "Home\PostController@mypost")->name("mypost");
Route::get('/post/edit/{id}', "Home\PostController@edit")->name("edit");
Route::post('/post/update', "Home\PostController@update")->name("update");
Route::get('/post/delete/{id}', "Home\PostController@delete")->name("delete");

// 搜索文章
Route::get('/post/search', "Home\PostController@search")->name("search");

// 我的收藏
Route::get('/post/myfav', "Home\PostController@myfav")->name("myfav");
Route::get('/post/detail/{id}', "Home\PostController@detail")->name("detail");

// 头像设置
Route::get('/user/seticon', "Home\UserController@seticon")->name("seticon");
Route::post('/user/saveicon', "Home\UserController@saveicon")->name("saveicon");


// 重置密码
Route::get('/user/resetpass', "Home\UserController@resetpass")->name("resetpass");
Route::post('/user/resetp', "Home\UserController@resetp")->name("resetp");


Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');

// 移动路由
Route::get('/m', function () {
    return view('m/master');
});

/*
Route::any('{all}', function () {
    return view('m/master');
})->where(['all' => '.*']);
*/


Route::get('/post/mlist', "Home\PostController@mlist"); // 所有文章

Route::get('/post/m_myfav', "Home\PostController@m_myfav"); // 所有文章

//　文章详情
Route::get('/post/m_detail/{id}', "Home\PostController@m_detail"); // 所有文章

// 搜索文章
Route::get('/post/m_search/{words}', "Home\PostController@m_search"); // 所有文章

